home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Today - The Disc! 5 / CD-ROM Today - The Disc (Issue 5)(November 1994).ISO / mac / HyperCard stackware / HyperCard Help / HyperCard Help.rsrc / TEXT_129_Messages.txt < prev    next >
Text File  |  1994-09-21  |  13KB  |  170 lines

  1.  
  2.    MESSAGES
  3.  
  4. --> the message hierarchy, and what messages HC sends...
  5.  
  6. A little terminology: A message can be sent (i) by HC in response to events ("system" message), or (ii) by a script ("handler" message), or (iii) from the Message box ("msg" message). A handler message or a msg message can be made up ("user-defined") or within HC's own known vocabulary ("pre-defined"); all system messages are pre-defined. A pre-defined message can be "informational" (it is sent purely to let handlers know what is happening) or a "command" (HC has a built-in action response to it). Command messages are marked * below; consult chapter "Commands" to find out what HC's built-in response is.
  7.  
  8.  
  9.  
  10. ΓîÑ2001           First Target
  11.  
  12.   The first place a system message is sent (by HyperCard) depends upon what the message is; it is always a button, field, or card (as described below).
  13.  
  14.   The first place a message from within a handler is sent is the object containing the handler -- unless the message is sent with the "send" command, in which case, you can have it start at any object in the current stack, or the stack script of another stack. You can also "send" a message direct "to HyperCard", bypassing the Hierarchy.
  15.  
  16.   The first place message from the message box is sent is the current card -- unless the message is sent with the "send" command, in which case, you can have it start at any object in the current stack, or the stack script of another stack. You can also "send" a message direct "to HyperCard", bypassing the Hierarchy.
  17.  
  18.  
  19.  
  20. ΓîÑ2001           The Hierarchy
  21.  
  22.  Static Path:
  23.    This is the normal order in which HC seeks a handler for a message or function call; it runs along this hierarchy looking for a handler, and stops when it finds one or continues if it finds one and is told to "pass" the message.
  24.  
  25.       button/field
  26. (Only certain system messages come here: mouse events on a button/field; messages with Button or Field in the name; and KeyDown, CommandKeyDown, and TabKey are sent to a field with the insertion point.)
  27.       current card
  28. (The recipient for all other system messages.)
  29.       current background
  30.       current stack
  31.       current stack XCMDs
  32.       most recently added "start using" stack
  33.       most recently added "start using" stack XCMDs
  34.       ...
  35.       first added "start using" stack
  36.       first added "start using" stack XCMDs
  37.       Home stack
  38.       Home stack XCMDs
  39.       HyperCard XCMDs
  40.       System XCMDs
  41.       HyperCard
  42. (At this point, if it's a pre-defined informational message, HC does nothing; if it's a pre-defined command, HC obeys it; otherwise [ie if it's a user-defined message], HC complains.)
  43.  
  44.  Dynamic Path:
  45.    When HC is executing a handler not on the static path of the current card, and if a message gets through the first stack level (including XCMDs) without being handled (or is handled there but "pass"ed), the "dynamic path" may be invoked, meaning that HC tries again, routing the message from the bottom of the other hierarchy. (Caution! The HyperTalk Reference stack states that a message must pass unhandled all the way to HyperCard before the dynamic path is invoked. This is not true!)
  46.    The rule for whether the dynamic path is invoked has to do with whether two different stacks are involved. If two different stacks are involved, the dynamic path is invoked either if the first path reaches the stack unhandled or if the first path is "pass"ed. If only one stack is involved, the dynamic path is invoked only if the first path reaches the stack totally unhandled.
  47.   Here are examples.
  48.  
  49.   Send:
  50.  
  51. (1) A button has a mouseUp handler 'send "MyMessage" to stack "OtherStack"'. Here is the hierarchy, whether the message is unhandled or it is handled but "pass"ed:
  52.       other stack
  53.       other stack XCMDs
  54.       original card
  55.       original background
  56.       original stack
  57.       original stack XCMDs
  58.       (etc.)
  59.  
  60. (2) A button on cd 1 has a mouseUp handler 'send "MyMessage" to cd 2'. Now things are different from situation (1). If MyMessage is handled at all, including if it is "pass"ed, on cd 2, or its background, or its stack (or stack XCMDs), the message just stops or else continues on the static path. If no handler for it at all is present in any of those places, it is sent to cd 1 (and then on up from there).
  61.  
  62.   Go: 
  63.  
  64. (1) A button has a mouseUp Handler 'go stack "OtherStack" / MyMessage'. Here is the hierarchy, whether the message is unhandled or it is handled but "pass"ed:
  65.       original button
  66.       original card
  67.       original background
  68.       original stack
  69.       original stack XCMDs
  70.       other stack's card
  71.       other stack's background
  72.       other stack
  73.       other stack XCMDs
  74.       (etc.)
  75.  
  76. (2) A button on cd 1 has a mouseUp Handler 'go cd 2 / MyMessage'. Now things are different from situation (1). If MyMessage is handled at all, including if it is "pass"ed, on the button, or cd 1, or its background, or its stack (or stack XCMDs), the message just stops or else continues on the static path. If no handler for it at all is present in any of those places, it is sent to cd 2 (and then on up from there).
  77.  
  78.  
  79.  
  80. ΓîÑ2001           Button Messages
  81.  
  82. newButton sent on creation; the button has no script (unless pasted)
  83. deleteButton sent just before the button vanishes
  84.  
  85. mouseEnter, mouseWithin (sent repeatedly), mouseLeave. With an Oval button, the "boundary" is the oval.
  86.  
  87. mouseDown, mouseStillDown (sent repeatedly), mouseUp; mouseDoubleClick which is sent only after the three messages for the first click have been sent, and if handlers for these involve dialogs ("answer" etc.) the MouseDoubleClick is never sent. With a Popup button, no MouseDoubleClick is sent, no MouseStillDown message is sent, and MouseUp is sent only if the mouse is released with the "menu". With an Oval button, the "boundary" is the oval. None of these messages is sent if the mouse is over a disabled button.
  88.  
  89.  
  90.  
  91. ΓîÑ2001           Field Messages
  92.  
  93. newField sent on creation; the field has no script (unless pasted)
  94. deleteField sent just before the field vanishes
  95.  
  96. mouseEnter, mouseWithin (sent repeatedly), mouseLeave
  97.  
  98. mouseDown, mouseStillDown (sent repeatedly), mouseUp; mouseDoubleClick -- all sent only to locked fields, except that MouseDown can be sent to an unlocked field by Γîÿ-clicking. MouseDoubleClick is sent only after the three messages for the first click have been sent, and if handlers for these involve dialogs ("answer" etc.) the MouseDoubleClick is never sent
  99.  
  100. openField sent to unlocked field when insertion point comes to be in it by mouseclick or tabkey, but not by HyperTalk e.g. "select text of..."
  101. exitField sent when user leaves field if no text was changed
  102. closeField sent when user leaves field if text was changed
  103.  
  104. *keyDown, *commandKeyDown
  105. *tabKey, *enterInField, *returnInField -- a KeyDown is sent before each. After a ReturnInField a TabKey will be sent if not intercepted and the insertion point is on the last line of a non-scrolling AutoKey field. After an EnterInField or TabKey the field will be closed and ExitField or CloseField will be sent; in the case of TabKey, the same or another field will then have its text selected, and OpenField will be sent.
  106.  
  107.  
  108.  
  109. ΓîÑ2001           Card Messages
  110.  
  111. These twelve are shown in the order of sending (whichever are appropriate):
  112. closeCard, closeBackground, closeStack
  113. deleteCard, deleteBackground, deleteStack but if you are deleting a stack, DeleteCard and DeleteBackground are not sent
  114. newStack, newBackground, newCard
  115. openStack, openBackground, openCard
  116.  
  117. startUp sent to first cd to be shown, but before it actually appears (before all Open... messages). Note that the Home stack performs some valuable tasks on StartUp (setting userLevel, fetching search paths, etc.) so it may be useful to Pass StartUp.
  118. quit sent after all Close... messages
  119.  
  120. moveWindow sent when the card window is moved by user or handler
  121. sizeWindow sent when the card window is resized by user or handler
  122. close sent before all Close... messages when closing this stack's card window, by user clicking in close box or by handler (but not when Close is chosen from the File menu); the window will not be closed unless the message reaches HyperCard. This is a subset of "close" messages generally, so you need to check the parameter to see if it is "card window"
  123. suspendStack sent when moving this stack's card window back from the front (even if screen is locked); no Close... messages are sent
  124. resumeStack sent when bringing this stack's card window to front from behind (even if screen is locked); no Open... messages are sent
  125.  
  126. mouseDown, mouseStillDown (sent repeatedly), mouseUp; mouseDoubleClick which is sent only after the three messages for the first click have been sent, and if handlers for these involve dialogs ("answer" etc.) the MouseDoubleClick is never sent
  127.  
  128. *keyDown, *commandKeyDown -- when it receives a commandKeyDown message, HC searches its menuItems for a visible, non-deleted equivalent, top to bottom starting with the rightmost menu; if it finds one it sends a doMenu, if not it beeps
  129. *tabKey, *enterKey, *returnKey, *controlKey, *arrowKey, *functionKey -- a KeyDown is sent before each. If the insertion point is in a field, EnterKey and ReturnKey are not sent (EnterInField and ReturnInField are sent instead); the prior KeyDown goes to the field, and so does TabKey, but ControlKey, FunctionKey and ArrowKey are sent to the card, bypassing the field.  If F1, F2, F3, or F4 is pressed and FunctionKey reaches HyperCard, the effect will be the sending of a DoMenu message for Undo, Cut, Copy, Paste respectively.
  130.  
  131. *doMenu sent when a menu item is chosen, via mouse or command key (in the latter case a CommandKeyDown will have preceded). The menu item will not be responded to unless the DoMenu message reaches HyperCard. If a menuItem with a menuMessage was chosen, that menuMessage will then be sent. Some of HC's menu items also have menuMessages which are then sent, and nothing will happen unless those messages reach HyperCard, namely:
  132. *help sent by the Help menu item
  133. *choose sent by any item in the Tools menu (including Γîÿ-TAB(-TAB-TAB) key shortcuts, which send CommandKeyDown first)
  134.  
  135. *show menubar, *hide menubar sent as a result of pressing Γîÿ-space (a CommandKeyDown precedes); the menubar will not be affected unless the message reaches HyperCard. These are special cases of the show/hide commands, so the parameter must be checked to see if it is menubar if you want to intervene
  136.  
  137. errorDialog sent if the LockErrorDialogs is true and an error occurs to which HyperCard would otherwise have responded with a dialog box
  138. appleEvent sent if an Apple Event arrives; the event will not be executed unless it reaches HyperCard
  139.  
  140. openPalette, openPicture; mouseDownInPicture, mouseUpInPicture; closePalette, closePicture (all products of the included Picture and Palette XCMDs) -- ClosePalette and ClosePicture are sent as byproducts when the user clicks in the close box, just before the window disappears (you can handle but not prevent the closing); if a handler closes with "close window...", though, only Close is sent 
  141.  
  142. idle sent repeatedly when Browse tool is current and no handler is executing
  143.  
  144. [resume, suspend sent under System 6 Finder (not MultiFinder) on launch or and return from another app. Under MultiFinder and System 7, no message is sent in such cases, nor when the user switches apps; if your stack needs to know whether HyperCard is backgrounded it can check the Suspended property in an Idle handler.]
  145.  
  146.  
  147.  
  148. ΓîÑ2001           Message Parameters
  149.  
  150. Your messages can include parameters by using the syntax "MyMessage parameter[,parameter...]" (for a handler message) or "MyFunction(parameter[,parameter...])" (for a function).
  151.  
  152. Your handler can receive parameters by starting with syntax "on MessageName var1[,var2...]", "function FuncName var1[,var2...]". (The variable names are local and can be anything you like.) Or, you can use the various Param functions.
  153.  
  154. Some system messages include parameters, as follows:
  155.   errorDialog TextThatWouldHaveAppearedInDialog
  156.   appleEvent Class,ID,Sender
  157.   doMenu MenuItem,MenuName
  158.   show/hide "Menubar"OrWhatever
  159.   close "card window"OrWhatever
  160.   choose "tool",ToolNumber
  161.   open/close-Palette/Picture WindowName,WindowID
  162.   mouseDownInPicture / mouseUpInPicture WindowName,Point
  163.   arrowKey "left"|"right"|"up"|"down"
  164.   keyDown KeyLetter
  165.   commandKeyDown KeyLetter
  166.   functionKey KeyNumber (1-15)
  167.   controlKey KeyNumber 1-127 according to the following mapping, showing key(s) typed with the controlKey down and the KeyNumber code generated: a/Home=1; b=2; c/Enter=3; d/End=4; e/Help=5; f=6; g=7; h/Delete=8; i/Tab=9; j=10; k/PageUp=11; l/PageDown=12; m/Return=13; n=14; o=15; p/Function=16; q=17; r=18; s=19; t=20; u=21; v=22; w=23; x=24; y=25; z=26; Esc/Clear/"["=27; LeftArrow/"\"=28; RightArrow/"]"=29; UpArrow=30; DownArrow/"-"=31; '=39; *=42; +=43; ","=44; "-"=45; "."=46; "/"=47; 0=48; 1=49; 2=50; 3=51; 4=52; 5=53; 6=54; 7=55; 8=56; 9=57; ";"=59; "="=61; ~=96; ForwardDelete=127
  168.  
  169.  
  170.